package com.sfx.other.多线程样例测试;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MainThread {

    private static InheritableThreadLocal<String> inheritableThreadLocal = new InheritableThreadLocal<>();

    public static void main(String[] args) {
        inheritableThreadLocal.set("Hello from main thread");

        ExecutorService executor = Executors.newFixedThreadPool(5);
        executor.submit(() -> {
            String data = inheritableThreadLocal.get();
            System.out.println("Data from child thread: " + data);
        });

        executor.shutdown();
    }
}